# 如果 a+b+c=1000，且 a^2+b^2=c^2（a,b,c 为自然数），如何求出所有a、b、c可能的组合?
import time
import random

def method1():
    startTime = time.time()
    for a in range(0,100):
        for b in range(0,1000):
            for c in range(0,1000):
                if a**2 + b**2 == c**2 and a+b+c == 1000:
                    print("a,b,c = %d,%d,%d" % (a,b,c))
    endTime = time.time()
    print("elapsed:%f" % (endTime - startTime))


def method2():
    startTime = time.time()
    for a in range(1001):
        for b in range(1001):
            c = 1000-a-b
            if a ** 2 + b ** 2 == c ** 2 and a + b + c == 1000:
                print("a,b,c = %d,%d,%d" % (a, b, c))
    endTime = time.time()
    print("elapsed:%f" % (endTime - startTime))

if __name__ == '__main__':
    # method1()
    method2()